package com.yidu.logisticssystem.service.impl;

import com.yidu.logisticssystem.entity.LogisticsBatch;
import com.yidu.logisticssystem.dao.LogisticsBatchDao;
import com.yidu.logisticssystem.service.LogisticsBatchService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 订单批次(LogisticsBatch)表服务实现类
 *
 * @author makejava
 * @since 2021-03-12 15:07:49
 */
@Service("logisticsBatchService")
public class LogisticsBatchServiceImpl implements LogisticsBatchService {
    @Resource
    private LogisticsBatchDao logisticsBatchDao;

    /**
     * 通过ID查询单条数据
     *
     * @param batchId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsBatch queryById(Integer batchId) {
        return this.logisticsBatchDao.queryById(batchId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsBatch> queryAllByLimit(int offset, int limit) {
        return this.logisticsBatchDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsBatch 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsBatch insert(LogisticsBatch logisticsBatch) {
        this.logisticsBatchDao.insert(logisticsBatch);
        return logisticsBatch;
    }

    /**
     * 修改数据
     *
     * @param logisticsBatch 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsBatch update(LogisticsBatch logisticsBatch) {
        this.logisticsBatchDao.update(logisticsBatch);
        return this.queryById(logisticsBatch.getBatchId());
    }

    /**
     * 通过主键删除数据
     *
     * @param batchId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer batchId) {
        return this.logisticsBatchDao.deleteById(batchId) > 0;
    }

    @Override
    public int insertfind(List<LogisticsBatch> user) {
        return 0;
    }

    /**
     * 根据批次号查询所有运单
     * @param batchNum
     * @return
     */
    @Override
    public String[] selectWayNum(String batchNum) {
        return logisticsBatchDao.selectWayNum(batchNum);
    }


}
